disk: Check if returned pointer for allocated memory is NULL
authorAlec Brown <alec.r.brown@oracle.com>
Wed, 22 Jan 2025 02:55:11 +0000 (02:55 +0000)
committerFelix Zielcke <fzielcke@z-51.de>
Thu, 3 Jul 2025 16:35:51 +0000 (18:35 +0200)
commit13706759be8655e3e167f17fd3e41395aeb3e58f
treedbcc60eacb39bbfc72082711465ae89e4f9aadc3
parent481990bd0aa31884828cebaf00b5a0e88545bd2b
disk: Check if returned pointer for allocated memory is NULL

When using grub_malloc(), grub_zalloc() or grub_calloc(), these functions can
fail if we are out of memory. After allocating memory we should check if these
functions returned NULL and handle this error if they did.

On the occasion make a NULL check in ATA code more obvious.

Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name disk-Check-if-returned-pointer-for-allocated-memory-is-NU.patch
grub-core/disk/ata.c
grub-core/disk/ieee1275/obdisk.c
grub-core/disk/ldm.c
grub-core/disk/lvm.c
grub-core/disk/memdisk.c